package com.zj.viewpagerdemo.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zj.viewpagerdemo.R;

/**
 * Created by Lenovo on 2017/4/25.
 */

public class MainFragment extends Fragment {

    private TextView textView;

    private String status;

    public static MainFragment newInstance(String status) {
        MainFragment fragment = new MainFragment();

        Bundle bundle = new Bundle();
        bundle.putString("status", status);
        fragment.setArguments(bundle);

        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        status = getArguments().getString("status");
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        return super.onCreateView(inflater, container, savedInstanceState);
        View view = LayoutInflater.from(container.getContext()).inflate(R.layout.fragment_main, container, false);

        textView = (TextView) view.findViewById(R.id.text_view);
        textView.setText("#Fragment: " + status);

        return view;
    }
}
